﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace iMagistic
{
    /// <summary>
    /// Interaction logic for SizeSelector.xaml
    /// </summary>
    public partial class SizeSelector : UserControl
    {
        public event EventHandler Click;

        public SizeSelector()
        {
            InitializeComponent();
        }

        private void Selected_Click(object sender, RoutedEventArgs e)
        {
            Button myBTn = sender as Button;
            string value = myBTn.Content.ToString();
            //MessageBox.Show(myBTn.Content.ToString());
            if (Click != null) Click(value, EventArgs.Empty);
        }

        private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
        {


            double canvasHeight = e.NewSize.Height;
            double canvasWidth = e.NewSize.Width;
            double ratioWidth;
            double ratioHeight;

            Btn20X30.Height = canvasHeight;
            Btn20X30.Width = canvasWidth;


            ratioWidth = (double)2539 / 2991;
            ratioHeight = (double)1795 / 2180;

            Btn15X21.Width = ratioWidth * canvasWidth;
            Btn15X21.Height = ratioHeight * canvasHeight;

            ratioWidth = (double)2126 / 3091;
            ratioHeight = (double)1500 / 2280;

            Btn13X18.Width = ratioWidth * canvasWidth;
            Btn13X18.Height = ratioHeight * canvasHeight;

            ratioWidth = (double)1795 / 3391;
            ratioHeight = (double)1205 / 2480;

            Btn10X15.Width = ratioWidth * canvasWidth;
            Btn10X15.Height = ratioHeight * canvasHeight;

            ratioWidth = (double)1500 / 3891;
            ratioHeight = (double)1051 / 3080;

            Btn09X13.Width = ratioWidth * canvasWidth;
            Btn09X13.Height = ratioHeight * canvasHeight;

        }
    }
}
